package com.xwyzsn.backend.job.controller;


import com.xwyzsn.backend.job.common.Result;
import com.xwyzsn.backend.job.service.impl.StudentServiceImpl;
import com.xwyzsn.backend.job.service.impl.TeacherServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xwyzsn
 * @since 2023-03-03
 */
@RestController
@RequestMapping("/job/user")
@CrossOrigin(origins = "*", maxAge = 3600)
public class UserController {

    @Autowired
    private StudentServiceImpl studentService;
    @Autowired
    private TeacherServiceImpl teacherService;


    @PostMapping("/login")
    public Result login(@RequestParam("username") String uname, @RequestParam("password") String pwd){
        Result result = studentService.login(uname, pwd);
        if(result.getCode()==400){
            return Result.fail("wrong user or password ");
        }
        return result;
    }

    @PostMapping("/update")
    public Result update(@RequestParam("username") String uname,
                         @RequestParam("password") String pwd,
                         @RequestParam("snum") String snum,
                         @RequestParam("age") Integer age,
                         @RequestParam("major") String major,
                         @RequestParam("tel") String tel,
                         @RequestParam("qq") String qq,
                         @RequestParam("confirmPassword") String confirmPassword,
                        @RequestParam("email") String email){
        return studentService.update(snum, confirmPassword,email,tel,qq);
    }

    
}
